import QtQuick 2.0
import QtGraphicalEffects 1.0
import QtQuick.Controls 2.5
import QtQuick 2.14

import "../basic"

TextField {
    // 重新设置渐变
    Connections {
        target: BasicConfig
        function onBlankAreaClicked() {
            innerRect.gradientStopPos = 1
        }
    }

    background: Rectangle {     // 外部矩形,当作边框
        anchors.fill: parent
        radius: 8
        gradient: Gradient {
            orientation: Gradient.Horizontal
            GradientStop { color: "#21283d"; position: 0 }
            GradientStop { color: "#382635"; position: 1 }
        }

        // 内部矩形
        Rectangle {
            id: innerRect
            anchors.fill: parent
            anchors.margins: 1
            radius: 8
            property real gradientStopPos: 1
            gradient: Gradient {
                orientation: Gradient.Horizontal
                GradientStop { color: "#1a1d29"; position: 0 }
                GradientStop { color: "#241c26"; position: innerRect.gradientStopPos }
            }
        }

        Image {
            id: serchIcon
            anchors.verticalCenter: parent.verticalCenter
            anchors.left: parent.left
            anchors.leftMargin: 8
            source: "qrc:/img/Resources/title/search.png"
            height: parent.height
            width: height
            scale: 0.8
        }

        MouseArea {
            anchors.fill: parent
            onClicked: {
                innerRect.gradientStopPos = 0
                searchPop.open()
                historyRep.showAll = false  // 重置
            }
        }
    }
}
